<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>欢迎登录安徽宣城医药</title>
<link rel="icon" href="<c:url value='/resources/images/bitbug_favicon.ico' />" mce_href="/dir/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="<c:url value='/resources/images/bitbug_favicon.ico' />" mce_href="<c:url value='/lib/website/images/favicon.ico' />" type="image/x-icon" />

<link href="<c:url value="/resources/styles/login.css" />" rel="stylesheet" type="text/css">
<!-- 版本兼容性选择 -->
<!--[if lt IE 9]>
	<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.11.1.min.js" />"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
    <script type="text/javascript" src="<c:url value="/resources/js/jquery-2.1.0.min.js" />"></script>
<!--<![endif]-->
<!-- 弹出 +提示插件 -->
<script src="<c:url value="/js/plug/layer-v1.8.5/layer/layer.min.js" />"></script>
</head>
<style>
.form-control{
	height: 40px;
}
</style>
<body>
<%
	String lastUrl = request.getParameter("lastUrl");
	lastUrl=lastUrl==null?"":lastUrl;
%>
<div class="wrap head">  
	<a href="<c:url value="/" />" class="logo"><img align="middle" id="yao_logo" src="<c:url value='/resources/images/common/logo.jpg' />"></a>    
    <div class="mod_tell"> <p><a href="<c:url value="/" />">&nbsp;&nbsp;&nbsp;24小时客服热线</a></p>          <div class="tellnumber">4001880170</div>        </div>
</div> 
<div class="wrap login_wrap">
    <h2 class="lg_title"><span class="fr">还不是安徽宣城医药会员？<a href="javascript:alert('请联系宣城');" class="blue_link">会员申请</a></span>Hi，欢迎登录！</h2>
	<form class="login-bd" id="loginForm" name="loginForm" action="<c:url value='/user/login.s'/>" method="post"  >
	<input type="hidden" value="WEB" name="loginFrom" >
	<input type="hidden" value="<%=lastUrl %>" name="lastUrl" >
	<div class="reg_form reg_form_step2">
        <div class="reg_row">
                <!-- 用户名 -->
                <input type="text" name="loginName" id="TxtUserName" autocomplete="off" placeholder="注册账号|采购商|业务员|供货商" class="form-control u_name" value="">
                <c:if test="${not empty result && result.code eq '100'}">
                	<c:if test="${result.data.errorType eq 'loginName'}">
                			<script>
								$("#TxtUserName").focus();
	                		</script>
                		<span id="accountDesc" class="error" style="display: block;">
                			${result.result}
                		</span>
                	</c:if>
                </c:if>
                
        </div>
         <div class="reg_row">      
                <!-- 密码 -->
                <input type="password" id="TxtPassword" name="loginPwd" autocomplete="off" placeholder="登录密码" class="form-control u_ps" value="">
                <span class="fr"><a href="###" id="forgetPwd" class="blue_link">忘记密码？</a></span>
                 <c:if test="${not empty result && result.code eq '100'}">
                	<c:if test="${result.data.errorType eq 'loginPwd'}">
                			<script>
								$("#TxtPassword").focus();
	                		</script>
                		<span id="pwd_desc" class="error" style="display: block;">
                			${result.result}
                		</span>
                	</c:if>
                </c:if>
        </div>
         
        <div id="vcd_div" class="reg_row verify_box" >
        		<div>
                <input type="text" maxlength="4" id="vcd" tabindex="-1" name="validCode" placeholder="验证码" class="form-control u_verify">
                <i id="vcd_tatus"></i>
                <img id="loginVcode" class="code verifyimg" src="<c:url value='/views/jsp/include/inc_validCode.jsp' />" onclick="this.src='<c:url value='/views/jsp/include/inc_validCode.jsp' />?t='+(new Date()).getTime()" alt="验证码">
				<a class="verifylink" style="width: 66px;" id="changecode" tabindex="-1" href="javascript:void(0);">换一张</a>
				</div>
					<c:if test="${not empty result && result.code eq '100'}">
	                	<c:if test="${result.data.errorType eq 'validCode'}">
	                		<script>
								$("#vcd").focus();
	                		</script>
	                		<span id="vcd_desc" class="error" style="display: block;">
	                		${result.result}
	                		</span>
	                	</c:if>
	                </c:if>
        </div>
         
         <div class=""> 
                
<!--                 <label class="checkbox">
                	<input type="checkbox" value="1" name="rememberPwd" id="rememberPwd" tabindex="-1">
                    <span class="two_week" style="width: 150px;float: left;">两周内免登录</span>
                                      
                </label> -->
               
                <button type="button"  class="btn btn-primary" onclick="sub()">登录</button>
        </div>
        
        <!-- 
         <label class="checkbox">
                 		方便测试账号：DWI00000675 abc@123456  上线后删除
                </label>
        <div class="reg_row hz_login"> 
        	<p>网站测试运行阶段  测试账号如下,需配合后台权限设置：</p>
		             采购商：DWI00000675   abc@123456  <br>
		             供货商：GYS  abc@123456<br>
		             供货商业务员：GHSYWY  abc@123456 <br>
		             宣城业务员：YWY  abc@123456<br>
		             普通用户：CUSTOMER abc@123456<br>
        </div>
         -->
        
    </div>
  </form>
</div>

<div id="simplefooter">
	<c:import url="/views/jsp/include/footer_1.jsp"></c:import>
</div>
    
<script>
 
function sub(){
	if($("#TxtUserName").val()==null || $("#TxtUserName").val()==""){
		$("#TxtUserName").focus();
		return false;
	}
	if($("#TxtPassword").val()==null || $("#TxtPassword").val()==""){
		$("#TxtPassword").focus();
		return false;
	}
	if($("#vcd").val()==null || $("#vcd").val()==""){
		$("#vcd").focus();
		return false;
	}
	$("#TxtPassword").val(base64encode(utf16to8($("#TxtPassword").val())));
	
	$("#loginForm").submit();
}

$(function(){
	layer.use('extend/layer.ext.js');

	//密码找回
	$("#forgetPwd").click(function(){
		layer.prompt({title: '输入您的 用户名!'}, function(userName){
			//验证邮件有效性
			if (!userName) {
				alert("请输入用户名！");
				return false;
		    }
			var loading ;
			//发送验证码
			$.ajax({
				type:"post",
				data:{"loginName":userName},
				url:"<c:url value="/user/sendFindPwdEmail.s" />",
				dataType:"json",
				beforeSend:function(){
					loading = layer.load('发送找回密码邮件中…');
				},
				success:function(data){
					layer.close(loading);
					if(data.code=="200"){
						layer.alert("发送邮件成功,请去邮箱"+data.data.user.email+"查收,有效期30分钟!");
					}else{
						layer.msg(data.result,1, {type: 8,shade: [0.2, '#ccc']});
					}
				}
			});
		});
	});

	$('#TxtUserName,#TxtPassword,#vcd').keydown(function(e){
		if(e.keyCode==13){
			//对密码进行传输加密
			sub();
		}
	});


	$("#changecode").click(function(){
		$("#loginVcode").attr("src","<c:url value='/views/jsp/include/inc_validCode.jsp' />?t='+(new Date()).getTime()");

	});
});

 
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var base64DecodeChars = new Array(
　　-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
　　-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
　　-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
　　52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
　　-1,　0,　1,　2,　3,  4,　5,　6,　7,　8,　9, 10, 11, 12, 13, 14,
　　15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
　　-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
　　41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
function base64encode(str) {
　　var out, i, len;
　　var c1, c2, c3;
　　len = str.length;
　　i = 0;
　　out = "";
　　while(i < len) {
 c1 = str.charCodeAt(i++) & 0xff;
 if(i == len)
 {
　　 out += base64EncodeChars.charAt(c1 >> 2);
　　 out += base64EncodeChars.charAt((c1 & 0x3) << 4);
　　 out += "==";
　　 break;
 }
 c2 = str.charCodeAt(i++);
 if(i == len)
 {
　　 out += base64EncodeChars.charAt(c1 >> 2);
　　 out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
　　 out += base64EncodeChars.charAt((c2 & 0xF) << 2);
　　 out += "=";
　　 break;
 }
 c3 = str.charCodeAt(i++);
 out += base64EncodeChars.charAt(c1 >> 2);
 out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
 out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
 out += base64EncodeChars.charAt(c3 & 0x3F);
　　}
　　return out;
}
function base64decode(str) {
　　var c1, c2, c3, c4;
　　var i, len, out;
　　len = str.length;
　　i = 0;
　　out = "";
　　while(i < len) {
 /* c1 */
 do {
　　 c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
 } while(i < len && c1 == -1);
 if(c1 == -1)
　　 break;
 /* c2 */
 do {
　　 c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
 } while(i < len && c2 == -1);
 if(c2 == -1)
　　 break;
 out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
 /* c3 */
 do {
　　 c3 = str.charCodeAt(i++) & 0xff;
　　 if(c3 == 61)
　return out;
　　 c3 = base64DecodeChars[c3];
 } while(i < len && c3 == -1);
 if(c3 == -1)
　　 break;
 out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
 /* c4 */
 do {
　　 c4 = str.charCodeAt(i++) & 0xff;
　　 if(c4 == 61)
　return out;
　　 c4 = base64DecodeChars[c4];
 } while(i < len && c4 == -1);
 if(c4 == -1)
　　 break;
 out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
　　}
　　return out;
}
function utf16to8(str) {
　　var out, i, len, c;
　　out = "";
　　len = str.length;
　　for(i = 0; i < len; i++) {
 c = str.charCodeAt(i);
 if ((c >= 0x0001) && (c <= 0x007F)) {
　　 out += str.charAt(i);
 } else if (c > 0x07FF) {
　　 out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
　　 out += String.fromCharCode(0x80 | ((c >>　6) & 0x3F));
　　 out += String.fromCharCode(0x80 | ((c >>　0) & 0x3F));
 } else {
　　 out += String.fromCharCode(0xC0 | ((c >>　6) & 0x1F));
　　 out += String.fromCharCode(0x80 | ((c >>　0) & 0x3F));
 }
　　}
　　return out;
}
function utf8to16(str) {
　　var out, i, len, c;
　　var char2, char3;
　　out = "";
　　len = str.length;
　　i = 0;
　　while(i < len) {
 c = str.charCodeAt(i++);
 switch(c >> 4)
 {
　 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
　　 out += str.charAt(i-1);
　　 break;
　 case 12: case 13:
　　 char2 = str.charCodeAt(i++);
　　 out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
　　 break;
　 case 14:
　　 char2 = str.charCodeAt(i++);
　　 char3 = str.charCodeAt(i++);
　　 out += String.fromCharCode(((c & 0x0F) << 12) |
　　　　((char2 & 0x3F) << 6) |
　　　　((char3 & 0x3F) << 0));
　　 break;
 }
　　}
　　return out;
}

 
</script>
 </body>
</html>